<%@ page language="java" contentType="text/html; charset=UTF-8"	 pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>
<!DOCTYPE html>
<html>
<head>
</head>
  <title>城市调研管理</title>
 <style type="text/css">
	.layui-form-select dl {
		max-height: 150px;
	}
	.fieldset{
		margin-top: 5px;
		margin-bottom: 0px
	}
	.layui-legend{
		background-color:#5fb878;
		font-size:15px !important;
		width:150px;
	}
	.layui-form-item {
	    margin-bottom: 5px;
	    clear: both;
	    *zoom: 1;
	}
	.layui-form-label{width: 159px;}
	.right{
		float:right;
	}
	.width106{
		width:106px;
	}
	.width98{
		width:98px;
	}
	.width60{
		width:60px;
	}
	.width30{
		width:30px;
	}
</style>
</head>
<body>

<div class="layui-fluid">
<div class="layui-card">
    <!-- 查询区域  -->
    <div id="query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">城市名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="cityName" placeholder="请输入" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">城市级别</label>
                <div class="layui-input-inline">
                    <select name="cityLevel" >
                        <option value="">请选择</option>
                        <option value="1">直辖市</option>
                        <option value="2">省会</option>
                        <option value="3">地级市</option>
                        <option value="4">百强县</option>
                        <option value="5">区县</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline" >
                <label class="layui-form-label" >区域所属级别</label>
                <div class="layui-input-inline">
                    <select name="areaLevel" >
                        <option value="">请选择</option>
                        <option value="1">核心市场</option>
                        <option value="2">发展市场</option>
                        <option value="3">择机市场</option>
                        <option value="4">其他</option>
                    </select>
                </div>
            </div>
            <shiro:hasPermission name="LIST_CITYSURVEY">
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-citySurveyInfo-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
                    </button>
                    <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-user-back-reset">
                        <i class="layui-icon layui-icon-fonts-clear  layuiadmin-button-btn"></i>重置
                    </button>
                </div>
            </shiro:hasPermission>
        </div>
    </div>
    <!-- 按钮区域  -->
    <div class="layui-card-body">
        <div style="padding-bottom: 10px;">
            <shiro:hasPermission name="ADD_CITYSURVEY">
                <button class="layui-btn layuiadmin-btn-admin " data-type="add" id="btnAdd">
                    <i class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>新增
                </button>
            </shiro:hasPermission>
        </div>
        <!-- 数据表单 -->
        <table id="LAY-citySurvey-manage" lay-filter="LAY-citySurvey-manage"></table>

        <!-- 添加城市调研信息 -->
        <form class="layui-form" lay-filter="add_form" id="add_form" style="padding: 20px 30px 0 0;display:none">
            <fieldset class="layui-elem-field layui-field-title fieldset"  id="baseInfo">
                <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">基础信息></legend>
            </fieldset>
            <div class="layui-form-item" style="height:10px;"></div>
            <div class="layui-form-item">
                <label class="layui-form-label" >城市名称</label>
                <div class="layui-input-inline">
                    <select name ="refProvinceId"  id="add_detail_select_provinceId" lay-filter="add_detail_select_provinceId" lay-verify="required" lay-search>
                        <option value="">请选择</option>
                        <c:if test="${not empty provinces }">
	              			<c:forEach items="${provinces}" var="province">
	              				<option value="${province.id}">${province.sname }</option>
		            		</c:forEach>
	              		</c:if>
                    </select>
                </div>
                <div class="layui-input-inline" >
                    <select name="refCityId" id="select_city" lay-filter="select_city" lay-verify="required" lay-search>
                    </select>
                </div>
                <div class="layui-input-inline">
                    <select name="refAreaId" id="select_area" lay-filter="select_area"  lay-search>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label" >城市级别</label>
						<div class="layui-input-inline">
							<div class="layui-input-inline">
			                    <select name="cityLevel" lay-verify="required" lay-search>
			                        <option value="">请选择</option>
			                        <option value="1">直辖市</option>
			                        <option value="2">省会</option>
			                        <option value="3">地级市</option>
			                        <option value="4">百强县</option>
			                        <option value="5">区县</option>
			                    </select>
                			</div>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label" >区域所属级别</label>
							<div class="layui-input-inline">
			                    <select name="areaLevel" >
			                        <option value="">请选择</option>
			                        <option value="1">核心市场</option>
			                        <option value="2">发展市场</option>
			                        <option value="3">择机市场</option>
			                        <option value="4">其他</option>
                  			    </select>
               			 </div>
					</div>
				</div>
            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >城市人口（万人）</label>
                <div class="layui-input-inline">
                    <input type="text" name="popuNum" maxlength="30" lay-verify="required|doubleNumber" placeholder="请输入城市人口数"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
                 <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">城市经济信息></legend>
            </fieldset>
 			<div class="layui-form-item">
				<div class="layui-inline">
           			 <div class="layui-form-item layui-inline" style="width:100%;">
                <label class="layui-form-label" >GDP（亿元）</label>
                <div class="layui-input-inline">
                    <input type="text" name="gdp" maxlength="30" lay-verify="required|doubleNumber" placeholder="请输入GDP"
                           autocomplete="off" class="layui-input">
                </div>
                 </div>
            </div>
			<div class="layui-inline">
            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >财政总收入（亿元）</label>
                <div class="layui-input-inline">
                    <input type="text" name="sumAmount" maxlength="30" lay-verify="required|doubleNumber" placeholder="请输入财政总收入"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            </div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
           			 <div class="layui-form-item layui-inline" style="width:100%;">
                <label class="layui-form-label" >一般公共预算收入（亿元）</label>
                <div class="layui-input-inline">
                    <input type="text" name="pubIncome" maxlength="30" lay-verify="required|doubleNumber" placeholder="请输入一般公共预算收入"
                           autocomplete="off" class="layui-input">
                </div>
                 </div>
            </div>
			<div class="layui-inline">
            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >一般公共预算支出（亿元）</label>
                <div class="layui-input-inline">
                    <input type="text" name="pubPay" maxlength="30" lay-verify="required|doubleNumber" placeholder="请输入一般公共预算支出"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            </div>
			</div>

            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >年度ppp项目占一般公共预算支出比例比（%）</label>
                <div class="layui-input-inline">
                    <input type="text" name="pppPercent" maxlength="30" lay-verify="required|doubleNumber" placeholder="请输入比例"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
                 <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">城市市政府信息></legend>
            </fieldset>

			<div class="layui-form-item">
				<div class="layui-inline">
            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >本级政府市委书记</label>
                <div class="layui-input-inline">
                    <input type="text" name="focai" maxlength="30" lay-verify="required" placeholder="请输入本级政府市委书记"
                           autocomplete="off" class="layui-input">
                </div>
                </div>
            </div>

			<div class="layui-inline">
            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >本级政府市长</label>
                <div class="layui-input-inline">
                    <input type="text" name="mayor" maxlength="30" lay-verify="required" placeholder="请输入本级政府市长"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            </div>
            </div>

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
                <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">附件></legend>
            </fieldset>

			<div class="layui-form-item">
                <label class="layui-form-label" style="width: 151px;">支持pdf、excel、图片资料，可上传多张</label>
                <div class="layui-input-block">
                <div class="layui-upload">
                    <button type="button" class="layui-btn layui-btn-normal" id="1-upload-more">上传</button>
                    <div class="layui-upload-list" id="1-upload-more-list" >
				    </div>
				</div>
            	</div>
            </div>

            <div class="layui-form-item layui-hide">
                <input type="button" lay-submit lay-filter="add_form_submit" id="add_form_submit" value="确认">
            </div>
        </form>

        <!-- 编辑窗口 -->
         <form class="layui-form" lay-filter="edit_form" id="edit_form" style="padding: 20px 30px 0 0;display:none">
            <fieldset class="layui-elem-field layui-field-title">
                <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">基础信息></legend>
            </fieldset>
            <input type="hidden" name="id"/>
            <div class="layui-form-item">
                <label class="layui-form-label">城市名称</label>
                <div class="layui-input-inline">
                    <select name ="refProvinceId" id="edit_detail_select_provinceId" lay-filter="edit_detail_select_provinceId" lay-verify="required" lay-search>
                        <option value="">请选择</option>
                        <c:if test="${not empty provinces }">
	              			<c:forEach items="${provinces}" var="province">
	              				<option value="${province.id}">${province.sname }</option>
		            		</c:forEach>
	              		</c:if>
                    </select>
                </div>
                <div class="layui-input-inline">
                    <select name="refCityId" id="edit_select_city" lay-filter="edit_select_city" lay-verify="required" lay-search>
                    </select>
                </div>
                <div class="layui-input-inline">
                    <select name="refAreaId" id="edit_select_area" lay-filter="edit_select_area"  lay-search>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
				<div class="layui-inline">
		            <div class="layui-form-item">
		                <label class="layui-form-label">城市级别</label>
		                <div class="layui-input-inline">
		                    <select name="cityLevel" lay-verify="required">
		                        <option value="">请选择</option>
		                        <option value="1">直辖市</option>
		                        <option value="2">省会</option>
		                        <option value="3">地级市</option>
		                        <option value="4">百强县</option>
		                        <option value="5">区县</option>
		                    </select>
		                </div>
		            </div>
           		 </div>
					<div class="layui-inline">
			            <div class="layui-form-item" style="width:100%;">
			                <label class="layui-form-label">区域所属级别</label>
			                <div class="layui-input-inline">
			                    <select name="areaLevel" >
			                        <option value="">请选择</option>
			                        <option value="1">核心市场</option>
			                        <option value="2">发展市场</option>
			                        <option value="3">择机市场</option>
			                        <option value="4">其他</option>
			                    </select>
			                </div>
			            </div>
		        	 </div>
		     </div>

            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label">城市人口（万人）</label>
                <div class="layui-input-inline">
                    <input type="text" name="popuNum" maxlength="30" lay-verify="required" placeholder="请输入城市人口数"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
                 <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">城市经济信息></legend>
            </fieldset>

		 	<div class="layui-form-item">
				<div class="layui-inline">
           			 <div class="layui-form-item" style="width:100%;">
               			 <label class="layui-form-label" >GDP（亿元）</label>
               			 <div class="layui-input-inline">
                 		   <input type="text" name="gdp" maxlength="30" lay-verify="required" placeholder="请输入GDP"
                           autocomplete="off" class="layui-input">
                		</div>
           		 	</div>
            	</div>

			<div class="layui-inline">
            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >财政总收入（亿元）</label>
                <div class="layui-input-inline">
                    <input type="text" name="sumAmount" maxlength="30" lay-verify="required" placeholder="请输入财政总收入"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            </div>
            </div>

			<div class="layui-form-item">
				<div class="layui-inline">
		            <div class="layui-form-item" style="width:100%;">
		                <label class="layui-form-label" >一般公共预算收入（亿元）</label>
		                <div class="layui-input-inline">
		                    <input type="text" name="pubIncome" maxlength="30" lay-verify="required" placeholder="请输入一般公共预算收入"
		                           autocomplete="off" class="layui-input">
		                </div>
		            </div>
		        </div>

				<div class="layui-inline">
		            <div class="layui-form-item" style="width:100%;">
		                <label class="layui-form-label" >一般公共预算支出（亿元）</label>
		                <div class="layui-input-inline">
		                    <input type="text" name="pubPay" maxlength="30" lay-verify="required" placeholder="请输入一般公共预算支出"
		                           autocomplete="off" class="layui-input">
		                </div>
            	</div>
            	</div>
            </div>

            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >年度ppp项目占一般公共预算支出比例比（%）</label>
                <div class="layui-input-inline">
                    <input type="text" name="pppPercent" maxlength="30" lay-verify="required" placeholder="请输入比例"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
                 <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">城市市政府信息></legend>
            </fieldset>

			<div class="layui-form-item">
				<div class="layui-inline">
		            <div class="layui-form-item" style="width:100%;">
		                <label class="layui-form-label" >本级政府市委书记</label>
		                <div class="layui-input-inline">
		                    <input type="text" name="focai" maxlength="30" lay-verify="required" placeholder="请输入本级政府市委书记"
		                           autocomplete="off" class="layui-input">
		                </div>
		            </div>
		        </div>

			<div class="layui-inline">
	            <div class="layui-form-item" style="width:100%;">
	                <label class="layui-form-label" >本级政府市长</label>
	                <div class="layui-input-inline">
	                    <input type="text" name="mayor" maxlength="30" lay-verify="required" placeholder="请输入本级政府市长"
	                           autocomplete="off" class="layui-input">
	                </div>
	            </div>
	         </div>
	     </div>

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
                 <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">附件></legend>
            </fieldset>

			<div class="layui-form-item">
                <label class="layui-form-label" style="width: 151px;">支持pdf、excel、图片资料，可上传多张</label>
                <div class="layui-input-block">
                <div class="layui-upload">
                    <button type="button" class="layui-btn layui-btn-normal" id="1-upload-more-edit">上传</button>
                    <div class="layui-upload-list" id="1-upload-more-list-edit" >
				    </div>
				</div>
            	</div>
            </div>

            <div class="layui-form-item layui-hide">
                <input type="button" lay-submit lay-filter="edit_form_submit" id="edit_form_submit" value="确认">
            </div>
        </form>

        <!-- 详细窗口 -->
        <div class="layui-form" lay-filter="detail_form" id="detail_form" style="padding: 20px 30px 0 0;display:none">
            <fieldset class="layui-elem-field layui-field-title">
                <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">基础信息></legend>
            </fieldset>
         	<div class="layui-form-item">
				<div class="layui-inline">
            <div class="layui-form-item">
                <label class="layui-form-label" >城市名称</label>
                <div class="layui-input-inline">
                    <div class="layui-input-inline">
						<input type="text" name="cityName" style="border:0px;" readonly="readonly" class="layui-input">
					</div>
                </div>
               </div>
            </div>
            <div class="layui-inline">
            <div class="layui-form-item">
                <label class="layui-form-label" >城市级别</label>
                <div class="layui-input-inline">
                    <select disabled="disabled" name="cityLevel" lay-verify="required">
                        <option value="">请选择</option>
                        <option value="1">直辖市</option>
                        <option value="2">省会</option>
                        <option value="3">地级市</option>
                        <option value="4">百强县</option>
                        <option value="5">区县</option>
                    </select>
                </div>
               </div>
            </div>
           </div>

			<div class="layui-form-item">
				<div class="layui-inline">
            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >区域所属级别</label>
                <div class="layui-input-inline">
                    <select disabled="disabled" name="areaLevel" >
                        <option value="">请选择</option>
                        <option value="1">核心市场</option>
                        <option value="2">发展市场</option>
                        <option value="3">择机市场</option>
                        <option value="4">其他</option>
                    </select>
                </div>
            </div>
            </div>

			<div class="layui-inline">
            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >城市人口（万人）</label>
                 <div class="layui-input-inline">
						<input type="text" name="popuNum" style="border:0px;" readonly="readonly" class="layui-input">
					</div>
            </div>
            </div>
            </div>

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
                  <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">城市经济信息></legend>
            </fieldset>

			<div class="layui-form-item">
				<div class="layui-inline">
            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >GDP（亿元）</label>
                <div class="layui-input-inline">
						<input type="text" name="gdp" style="border:0px;" readonly="readonly" class="layui-input">
					</div>
            </div>
            </div>
			<div class="layui-inline">
            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >财政总收入（亿元）</label>
                <div class="layui-input-inline">
						<input type="text" name="sumAmount" style="border:0px;" readonly="readonly" class="layui-input">
					</div>
            </div>
         </div>
        </div>

		<div class="layui-form-item">
				<div class="layui-inline">
            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >一般公共预算收入（亿元）</label>
                <div class="layui-input-inline">
						<input type="text" name="pubIncome" style="border:0px;" readonly="readonly" class="layui-input">
					</div>
            </div>
            </div>
			<div class="layui-inline">
            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >一般公共预算支出（亿元）</label>
                <div class="layui-input-inline">
						<input type="text" name="pubPay" style="border:0px;" readonly="readonly" class="layui-input">
					</div>
            </div>
           </div>
            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >年度ppp项目占一般公共预算支出比例比（%）</label>
                <div class="layui-input-inline">
						<input type="text" name="pppPercent" style="border:0px;" readonly="readonly" class="layui-input">
					</div>
            </div>

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
                 <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">城市市政府信息></legend>
            </fieldset>

			<div class="layui-form-item">
				<div class="layui-inline">
		            <div class="layui-form-item" style="width:100%;">
		                <label class="layui-form-label" >本级政府市委书记</label>
		                <div class="layui-input-inline">
								<input type="text" name="focai" style="border:0px;" readonly="readonly" class="layui-input">
							</div>
		            </div>
		        </div>

			<div class="layui-inline">
            <div class="layui-form-item" style="width:100%;">
                <label class="layui-form-label" >本级政府市长</label>
                <div class="layui-input-inline">
						<input type="text" name="mayor" style="border:0px;" readonly="readonly" class="layui-input">
					</div>
            </div>
            </div>
            </div>

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
                 <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">附件></legend>
            </fieldset>
             <div class="layui-form-item">
                <div class="layui-input-block">
                <div class="layui-upload">
                    <div class="layui-upload-list" id="1-upload-more-list-view" style="padding-left:62px">
				    </div>
				</div>
            	</div>
            </div>

			<fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
                 <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">保存记录></legend>
            </fieldset>
			<div class="layui-form-item">
				<div class="layui-inline" style="padding-left: 185px;">
					<table id="citySurveyInfoLog" class="lay-table">
					</table>
				</div>
			</div>

            <div class="layui-form-item layui-hide">
                <input type="button" lay-submit lay-filter="add_form_submit" id="add_form_submit" value="确认">
            </div>
        </div>
    </div>
</div>
</div>
</div>

<script>
    layui.config({
        base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'set', 'laydate', 'layedit', 'upload'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table
            , layedit = layui.layedit
            , laydate = layui.laydate
            , upload = layui.upload;

        form.verify({
    		//验证汉字
    	    CHS: [
    	    	/^[\u0391-\uFFE5]+$/
    	    	,'只能输入汉字'
    	  	],
	    	//大于0的正整数
		  	intNumber:[
				/^[1-9]\d*$/
				,'请输入正确的数字'
		  	],
		  	yearNumber:[
				/[0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3}/
				,'请输入正确的年份'
		  	],
		  	telNumber:[/^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\d{8}$|^0\d{2,3}-?\d{7,8}$/
		  		,'请输入正确的号码'
		  	],
		  	//大于0的对多保留2位小数正数
		  	doubleNumber:[
				/^\d+(\.\d{0,2})?$/
				,'请输入正确的数字'
		  	]
		});

        // 表单
        table.render({
            elem: '#LAY-citySurvey-manage'
            , url: basePath + '/citySurvey/queryCitySurvey' //请求数据接口
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'cityCode', title: '城市ID'}
                , {field: 'cityName', title: '城市名称'}
                , {
                    field: 'addTime', title: '创建时间', templet: function (d) {
                        return layui.util.toDateString(d.addTime, "yyyy-MM-dd HH:mm:ss");
                    }
                }
                , {
                    field: 'cityLevel', title: '城市级别', templet: function (d) {
                        if (d.cityLevel == 1) {
                            return "直辖市";
                        } else if (d.cityLevel == 2) {
                            return "省会";
                        } else if (d.cityLevel == 3) {
                            return "地级市";
                        } else if (d.cityLevel == 4) {
                            return "百强县";
                        } else if (d.cityLevel == 5) {
                            return "区县";
                        }
                    }
                }
                , {
                    field: 'areaLevel', title: '区域所属级别', templet: function (d) {
                        if (d.areaLevel == 1) {
                            return "核心市场";
                        } else if (d.areaLevel == 2) {
                            return "发展市场";
                        } else if (d.areaLevel == 3) {
                            return "择机市场";
                        } else if (d.areaLevel == 4) {
                            return "其他";
                        }
                    }
                }
                , {
                    field: 'uptTime', title: '最后保存时间', templet: function (d) {
                        return layui.util.toDateString(d.addTime, "yyyy-MM-dd HH:mm:ss");
                    }
                }
                ,{field: 'srealName', title: '最后修改人',templet:function (d) {
                        if (d.operator&&d.operator.srealName){
                            return d.operator.srealName
                        }else {
                            return  ''
                        }
                    }
                }
                , {
                    title: '操作', width: 170, align: 'center', fixed: 'right', templet: function (d) {
                        var optStr = "";
                        <shiro:hasPermission name="VIEW_CITYSURVEY">
                        	optStr += '<a class="layui-btn layui-btn-xs" lay-event="view"><i class="layui-icon layui-icon-form"></i>详情</a>';
                        </shiro:hasPermission>
                        <shiro:hasPermission name="UPDATE_CITYSURVEY">
                        	optStr += '<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>';
                        </shiro:hasPermission>
                        return optStr;
                    }
                }
            ]]
            , page: true
            , limit: 10
        });

     	// 新增-省份获取市
        form.on('select(add_detail_select_provinceId)', function(data){
        	var proId = data.value;
        	$('#select_city').html('');
        	$('#select_area').html('');
    		$.ajax({
    			type : "POST", //提交方式
    			url : basePath + '/citySurvey/getCityByPro',//路径
    			data : {
    				"proId" :proId
    			},//数据，这里使用的是Json格式进行传输
    			success : function(result) {//返回数据根据结果进行相应的处理
    				if(result.flag==true){
    					var strBuffer = "";
    					strBuffer+= '<option value="">请选择</option>';
    					layui.$.each(result.citys, function(i,item){
    						if(item.id != null && item.sname != null){
    							strBuffer+= '<option value='+item.id+'>'+item.sname+'</option>';
    						}
    			        });
    					$('#select_city').append(strBuffer);
    					form.render();
    				}else{
    					layer.msg('数据通信异常~',{icon: 0});
    				}
    			}
    		});
    	});

    	// 新增-市获取县
        form.on('select(select_city)', function(data){
        	var cityId = data.value;
        	$('#select_area').html('');
    		$.ajax({
    			type : "POST", //提交方式
    			url : basePath + '/citySurvey/getAreaByCity',//路径
    			data : {
    				"cityId" :cityId
    			},//数据，这里使用的是Json格式进行传输
    			success : function(result) {//返回数据根据结果进行相应的处理
    				if(result.flag==true){
    					var strBuffer = "";
    					strBuffer+= '<option value="">请选择</option>';
    					layui.$.each(result.areas, function(i,item){
    						if(item.id != null && item.sname != null){
    							strBuffer+= '<option value='+item.id+'>'+item.sname+'</option>';
    						}
    			        });
    					$('#select_area').append(strBuffer);
    					form.render();
    				}else{
    					layer.msg('数据通信异常~',{icon: 0});
    				}
    			}
    		});
    	});

     	// 修改-省份获取市
        form.on('select(edit_detail_select_provinceId)', function(data){
        	var proId = data.value;
        	$('#edit_select_city').html('');
        	$('#edit_select_area').html('');
    		$.ajax({
    			type : "POST", //提交方式
    			url : basePath + '/citySurvey/getCityByPro',//路径
    			data : {
    				"proId" :proId
    			},//数据，这里使用的是Json格式进行传输
    			success : function(result) {//返回数据根据结果进行相应的处理
    				if(result.flag==true){
    					var strBuffer = "";
    					strBuffer+= '<option value="">请选择</option>';
    					layui.$.each(result.citys, function(i,item){
    						if(item.id != null && item.sname != null){
    							strBuffer+= '<option value='+item.id+'>'+item.sname+'</option>';
    						}
    			        });
    					$('#edit_select_city').append(strBuffer);
    					form.render();
    				}else{
    					layer.msg('数据通信异常~',{icon: 0});
    				}
    			}
    		});
    	});

    	// 修改-市获取县
        form.on('select(edit_select_city)', function(data){
        	var cityId = data.value;
        	$('#edit_select_area').html('');
    		$.ajax({
    			type : "POST", //提交方式
    			url : basePath + '/citySurvey/getAreaByCity',//路径
    			data : {
    				"cityId" :cityId
    			},//数据，这里使用的是Json格式进行传输
    			success : function(result) {//返回数据根据结果进行相应的处理
    				if(result.flag==true){
    					var strBuffer = "";
    					strBuffer+= '<option value="">请选择</option>';
    					layui.$.each(result.areas, function(i,item){
    						if(item.id != null && item.sname != null){
    							strBuffer+= '<option value='+item.id+'>'+item.sname+'</option>';
    						}
    			        });
    					$('#edit_select_area').append(strBuffer);
    					form.render();
    				}else{
    					layer.msg('数据通信异常~',{icon: 0});
    				}
    			}
    		});
    	});

       upload.render({
	      elem: '#1-upload-more'
	      ,url: basePath + '/citySurvey/uploadAtt/'
	      ,data: {
	    	  types:1
	    		}
	      ,multiple: true
	      ,accept: 'file'
	      ,acceptMime: 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf'
	   	  ,before: function(obj){ //obj参数包含的信息
	   		    layer.load(); //上传loading
	   		  }
	      ,done: function(res){
	    	  //如果上传失败
	          if(res.code > 0){
	        	  layer.closeAll('loading'); //关闭loading
	        	  return layer.msg(res.msg,{icon: 7});
	          }
	          //上传完毕
	   	  	  if(res.entity != null && res.entity.length > 0){
				for(var i in res.entity){
					var citySurvey = res.entity[i];
					var arr = citySurvey.split("|");
					var imgSrc = "";
					var suffix = arr[1].substring(arr[1].lastIndexOf(".")+1,arr[1].length);
					if(suffix == 'jpg' || suffix == 'png'){
						imgSrc = "${fileHttpPre}/"+arr[3];
					}else{
						imgSrc = "${ctx}/resources/images/"+suffix+".jpg";
					}
	        		$('#1-upload-more-list')
	        		.append('<div class="layui-upload-img-div" id="upload_img_'+arr[2]+'"><img src="'+imgSrc+'" title="'
	        				+ arr[1] +'" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\''+"${fileHttpPre}"
	        						+arr[3] +'\');">查看</a><a href="javascript:void(0)" onclick="del(\''
	        								+arr[2]+'\')";>删除</a></div><p>'+arr[1]+'</p><input type="hidden" value="'
	        								+citySurvey+'" id="fileAtt_'+arr[2]+'" name="fileAtt" ></input></div> ');
				}
		  	  }
	      }
	      ,allDone: function(obj){ //当文件全部被提交后，才触发
	    	  layer.closeAll('loading'); //关闭loading
	      }
	      ,error: function(){
	    	  layer.closeAll('loading'); //关闭loading
	          //上传失败
	          layer.msg("上传失败，请稍后再试~",{icon: 7});
	        }
	    });

       upload.render({
 	      elem: '#1-upload-more-edit'
 	      ,url: basePath + '/citySurvey/uploadAtt/'
 	      ,data: {
 	    	  types:1
 	    		}
 	      ,multiple: true
 	      ,accept: 'file'
 	      ,acceptMime: 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf'
 	   	  ,before: function(obj){ //obj参数包含的信息
 	   		    layer.load(); //上传loading
 	   		  }
 	      ,done: function(res){
 	    	  //如果上传失败
 	          if(res.code > 0){
 	        	  layer.closeAll('loading'); //关闭loading
 	        	  return layer.msg(res.msg,{icon: 7});
 	          }
 	          //上传完毕
 	   	  	  if(res.entity != null && res.entity.length > 0){
 				for(var i in res.entity){
 					var citySurvey = res.entity[i];
 					var arr = citySurvey.split("|");
 					var imgSrc = "";
 					var suffix = arr[1].substring(arr[1].lastIndexOf(".")+1,arr[1].length);
 					if(suffix == 'jpg' || suffix == 'png'){
 						imgSrc = "${fileHttpPre}/"+arr[3];
 					}else{
 						imgSrc = "${ctx}/resources/images/"+suffix+".jpg";
 					}
 	        		$('#1-upload-more-list-edit')
 	        		.append('<div class="layui-upload-img-div" id="upload_img_'+arr[2]+'"><img src="'+imgSrc+'" title="'
 	        				+ arr[1] +'" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\''+"${fileHttpPre}"
 	        						+arr[3] +'\');">查看</a><a href="javascript:void(0)" onclick="del(\''
 	        								+arr[2]+'\')";>删除</a></div><p>'+arr[1]+'</p><input type="hidden" value="'
 	        								+citySurvey+'" id="fileAtt_'+arr[2]+'" name="fileAtt" ></input></div> ');
 				}
 		  	  }
 	      }
 	      ,allDone: function(obj){ //当文件全部被提交后，才触发
 	    	  layer.closeAll('loading'); //关闭loading
 	      }
 	      ,error: function(){
 	    	  layer.closeAll('loading'); //关闭loading
 	          //上传失败
 	          layer.msg("上传失败，请稍后再试~",{icon: 7});
 	        }

 	    });

        <shiro:hasPermission name="LIST_CITYSURVEY">
        	//监听搜索
	    	form.on('submit(LAY-citySurveyInfo-search)', function(data){
		      	//执行重载
		      	table.reload('LAY-citySurvey-manage', {page: {curr: 1},
		        	where: trimData(data)
		      	});
	    	});
	    	//重置清空
		    form.on('submit(LAY-user-back-reset)', function(data){
		    	reset_form('query-form');
				form.render();
		    });
        </shiro:hasPermission>

        // 监听操作列
        table.on('tool(LAY-citySurvey-manage)', function(obj){
            var data = obj.data;
            if(obj.event === 'edit'){
                $('#edit_select_city').html('');
            	$('#edit_select_area').html('');
        		$.ajax({
        			type : "POST", //提交方式
        			url : basePath + '/citySurvey/getCityByPro',//路径
        			data : {
        				"proId" :data.refProvinceId
        			},//数据，这里使用的是Json格式进行传输
        			success : function(result) {//返回数据根据结果进行相应的处理
        				if(result.flag==true){
        					var strBuffer = "";
        					strBuffer+= '<option value="">请选择</option>';
        					layui.$.each(result.citys, function(i,item){
        						if(item.id != null && item.sname != null){
        							strBuffer+= '<option value='+item.id+'  '
      								if(item.id == data.refCityId){
      									strBuffer+= 'selected';
      								}
      								strBuffer+= ' >'+item.sname+'</option>';
        						}
        			        });
        					$('#edit_select_city').append(strBuffer);
        					form.render();
        				}else{
        					layer.msg('数据通信异常~',{icon: 0});
        				}
        			}
        		});
        		$.ajax({
        			type : "POST", //提交方式
        			url : basePath + '/citySurvey/getAreaByCity',//路径
        			data : {
        				"cityId" :data.refCityId
        			},//数据，这里使用的是Json格式进行传输
        			success : function(result) {//返回数据根据结果进行相应的处理
        				if(result.flag==true){
        					var strBuffer = "";
        					strBuffer+= '<option value="">请选择</option>';
        					layui.$.each(result.areas, function(i,item){
        						if(item.id != null && item.sname != null){
        							strBuffer+= '<option value='+item.id+'  '
      								if(item.id == data.refAreaId){
      									strBuffer+= 'selected';
      								}
      								strBuffer+= ' >'+item.sname+'</option>';
        						}
        			        });
        					$('#edit_select_area').append(strBuffer);
        					form.render();
        				}else{
        					layer.msg('数据通信异常~',{icon: 0});
        				}
        			}
        		});
        		form.val('edit_form',data); // 填充原值
                layer.open({
                    type: 1
                    ,title: '修改城市调研信息'
                    ,content: $('#edit_form')
                    ,area: layui.admin.screen() <  2 ? ['80%', '550px'] : ['850px','550px']
                    ,btn: ['确定', '取消']
                    ,btnAlign: 'c'
                    ,yes: function(index, layero){
                        var submitID = 'edit_form_submit'
                            ,submit = layero.contents().find('#'+ submitID);
                        //监听提交
                        form.on('submit('+ submitID +')', function(data){
                            //var field = data.field; //获取提交的字段
                            var field =$('#edit_form').serialize();
                            //提交 Ajax 成功后，静态更新表格中的数据
                            $.ajax({
                                type : 'post',
                                url : basePath + '/citySurvey/editCitySurvey',
                                data: field,
                                success:function(result){
                                    if(result.success){
                                        table.reload('LAY-citySurvey-manage'); //数据刷新
                                        layer.close(index); //关闭弹层
                                    }else{
                                        layer.msg(result.msg,{icon: 7});
                                    }
                                }

                            });
                        });
                        submit.trigger('click');
                    }
                });
             // 附件处理
             $('#1-upload-more-list-edit').html('');
           	 $.ajax({
     			type : "POST", //提交方式
     			url : "${ctx}/citySurvey/queryAttsById",//路径
     			data : {
     				id:data.id,
     			},//数据，这里使用的是Json格式进行传输
     			success : function(result) {//返回数据根据结果进行相应的处理
     				if(result.flag == true){
     					//渲染附件
     					for(var i in result.atts){
     						var att = result.atts[i];
     						var fileSuffix = att.fileSuffix;
     						fileSuffix = fileSuffix.split(".")[1];
     						var imgSrc = "";
     						if(fileSuffix == 'jpg' || fileSuffix == 'png'){
     							imgSrc = "${fileHttpPre}/"+att.filePath;
     						}else{
     							imgSrc = "${ctx}/resources/images/"+fileSuffix+".jpg";
     						}
     						//拼接隐藏按钮的值
   		   	  		  	 	var inputValue = "|" + att.fileName+att.fileSuffix+"|"+att.id+"|"+att.filePath;
     		        		$('#1-upload-more-list-edit')
     		        		.append('<div class="layui-upload-img-div" id="upload_img_'+att.id+'" ><img src="'+imgSrc+'" title="'
     		        				+ att.fileName +'" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\''+"${fileHttpPre}"
     		        						+ att.filePath +'\');">查看</a><a href="javascript:void(0)" onclick="del(\''
 	        								+att.id+'\')";>删除</a></div><p>'+ att.fileName +'</p><input type="hidden" value="'
	 	        								+inputValue+'" id="fileAtt_'+att.id+'" name="fileAtt" ></input></div> ');
     						}
     					  }
     					}
     				});

            } else if(obj.event === 'view'){
           	 table.render({
 	            elem: '#citySurveyInfoLog'
 	            ,url: basePath + '/citySurvey/selectLogsById?id='+data.id //请求数据接口
 	            ,cols: [[
 	              {field: 'saveTime', title: '保存时间',align:'center',width:220,
 	                templet:function(d){
 	                 return layui.util.toDateString(d.saveTime,"yyyy-MM-dd HH:mm:ss")
                 }}
                	  ,{field: 'saveName', title: '保存人',align:'center',width:220}
 	             ]]
 	            ,page: false
 	            ,limit: 10
 	         });
           	 // 附件
             $('#1-upload-more-list-view').html('');
           	 $.ajax({
     			type : "POST", //提交方式
     			url : "${ctx}/citySurvey/queryAttsById",//路径
     			data : {
     				id:data.id,
     			},//数据，这里使用的是Json格式进行传输
     			success : function(result) {//返回数据根据结果进行相应的处理
     				if(result.flag == true){
     					//渲染附件
     					for(var i in result.atts){
     						var att = result.atts[i];
     						var fileSuffix = att.fileSuffix;
     						fileSuffix = fileSuffix.split(".")[1];
     						var imgSrc = "";
     						if(fileSuffix == 'jpg' || fileSuffix == 'png'){
     							imgSrc = "${fileHttpPre}/"+att.filePath;
     						}else{
     							imgSrc = "${ctx}/resources/images/"+fileSuffix+".jpg";
     						}
     		        		$('#1-upload-more-list-view')
     		        		.append('<div class="layui-upload-img-div" id="upload_img_'+att.id+'"><img src="'+imgSrc+'" title="'
     		        				+ att.fileName +'" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" style="margin-left:32px" onclick="showImg(\''+"${fileHttpPre}"
     		        						+ att.filePath +'\');">查看</a></div><p>'+ att.fileName +'</p></div> ');
     						}
     					  }
     					}
     				});
            	//
                form.val('detail_form',data); // 填充原值
                layer.open({
                    type: 1
                    ,title: '城市调研详情'
                    ,content: $('#detail_form')
                    ,area: layui.admin.screen() <  2 ? ['80%', '550px'] : ['850px','550px']
                });
            }
        });

        // 按钮事件
        var active = {
            add: function () {
            	clean_form("add_form");//清空表单
                layer.open({
                    type: 1
                    , title: '添加城市调研信息'
                    , content: $('#add_form')
                    , area: layui.admin.screen() < 2 ? ['80%', '550px'] : ['850px','550px']
                    , btn: ['确定', '取消']
                    , btnAlign: 'c'
                    , yes: function (index, layero) {
                        var submitID = 'add_form_submit'
                            , submit = layero.contents().find('#' + submitID);

                        //监听提交
                        form.on('submit(' + submitID + ')', function (data) {
                             var field = data.field;
                            $.ajax({
                                type: 'post',
                                url: basePath + '/citySurvey/save',
                                data:  $('#add_form').serialize(),
                                success: function (result) {
                                    if (result.success) {
                                        table.reload('LAY-citySurvey-manage'); //数据刷新
                                        clean_form("add_form");//清空表单
                                        layer.close(index); //关闭弹层

                                    } else {
                                        layer.msg(result.msg, {icon: 7});
                                    }
                                }
                            });
                        });
                        submit.trigger('click');
                    }
                });
            }
        }

        // data-type事件
        $('.layui-btn.layuiadmin-btn-admin').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

    function del(index){
   		layui.$("#fileAtt_"+index).remove();
   		layui.$("#upload_img_"+index).remove();
   	}

   	//根据url查看文件
   	function showImg(url){
   		var openWin = window.open(url,'','left=410,height=768, width=1024, top=200,  toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
   	}

</script>
</body>
</html>
